package com.xxxx.server.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 密码合法性校验
 *
 * @author nathan-wang on 2020-10-18
 */
public class PwdUtil {
    public static Boolean isValidPwd(String pwd){
        Pattern pattern = null;
        Matcher matcher = null;
        Boolean flag = false;
        //合法密码的正则表达式——
         //合法性:同时包含数字字母:长度8~16
        String str="^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$";
        if (StringUtils.isNotBlank(pwd)){
            pattern = Pattern.compile(str);
            matcher = pattern.matcher(pwd);
            flag = matcher.matches();
        }
        return flag;
    }
}
